<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="initial-scale=1, maximum-scale=1, minimum-scale=1, user-scalable=no" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<title>我的足迹</title>
<link rel="stylesheet" href="/style/new/css/base.css">
<link rel="stylesheet" href="/style/new/css/swiper.min.css"/>
<link rel="stylesheet" href="/style/new/css/xshop.css?ver=20180527" />
<link rel="stylesheet" href="/style/new/mui/css/mui.min.css" />
<script src="/style/new/js/swiper.min.js"></script>
<script src="/style/new/js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script src="/style/new/js/xShop.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" src="/style/js/sweet-alert.min.js"></script>
<link type="text/css" rel="stylesheet" href="/style/css/sweet-alert.css">
</head>
<body>    	
<!--top-->	
<div class="xihuan-bot footprint">
	<ul id="content">
		<?php 
		if($this->data['data']){
			foreach ($this->data['data'] as $r) {
		?>
		<li class="xihuan-bot-each">
			<a href="/index/goodsdetail?goods_id=<?=$r['goods_id'] ?>">
				<div class="xihuan-bot-each-pic">
				<?php

	              if($r['market_price'] > $r['shop_price'])
	              {
	                $zhekou = number_format($r['shop_price'] / $r['market_price'],2,".","");
	                echo '<div class="zhekou">'.($zhekou * 10).'折</div>';
	                echo '<div class="sheng">省'.number_format($r['market_price'] - $r['shop_price'],2,".","").'</div>';
	              }

	              if($r['goods_number']==0)
	              {
	                echo '<div class="saleout">补货中</div>';
	              }
	              ?>
				<?php if ($r['thumb_pic']!=""){ ?>
					<img src="<?=$r['thumb_pic']?>" />
				<?php }else{?>
					<img src="/style/new/images/home/xihuan-pic1.png" />
				<?php } ?>
				</div>
				<h2 class="xihuan-bot-each-title"><?= $r['goods_name']; ?></h2>
				<div class="xihuan-bot-each-fonu">
				</div>
				<div class="xihuan-bot-each-fonu">
	            <!--  <p class="xihuan-bot-each-number">已销<?/*=$r['sales_count']; */?>笔</p>
	              <p class="xihuan-bot-each-kucun">库存<?/*=$r['goods_number']; */?>件</p>-->
	            </div>
				<div class="xihuan-bot-each-money">
                    <p class="xihuan-bot-each-money-left"><b><?= $r['shop_price']; ?></b></p>
					<?php
					if($r['market_price']>0)
					{

						echo '<del>'.$r['market_price'].'</del>';
					}
					?>
				</div>
			</a>
		</li>
		<?php 
			}
		}
		?>  
	</ul>
</div>


<div class="foot_clean"><span><img src="/style/new/images/me/icon_delete.png"></span>清空足迹</div>
<script type="text/javascript">
var _page = <?=$this->data['page'] > 0 ? $this->data['page'] : 1;?>,
_maxpage = <?=$this->data['maxpage'] > 0 ? $this->data['maxpage'] : 1;?>,
_loading = false;
function isIphoneX(){
    return /iphone/gi.test(navigator.userAgent) && (screen.height == 812 && screen.width == 375)
}    
$(document).ready(function(e){
    // 判断iPhoneX
    if(isIphoneX())
    {
        $(".foot_clean,.xihuan-bot").addClass("iPhoneX");
    }

    $(document).on("scroll",function(){
    	if($(document).scrollTop() + $(window).height() + 200 >=$(document).height() && !_loading)
    	{
    		_loading = true;
    		_loadMore(_page +1);
    	}
    });

});

function _loadMore(page) {
    if (page <= _maxpage && _loading) {
        _page = page;
        $.post("/user/ajax", {
            "act": "getfootprint",
            "page": page,
            "mr": Math.random()
        }, function(json) {
            _loading = false;
            console.log(json);
            if (json.page == page && typeof json.data != "undefined" && json.data != null) {
                $.each(json.data, function(i, v) {
                    var _dpic = '/style/new/images/home/xihuan-pic1.png',
                        _del = '';
                    if (typeof v.thumb_pic != "undefined" && v.thumb_pic != null) {
                        _dpic = v.thumb_pic;
                    }
                    if (v.market_price > 0) {
                        _del = '<del>' + v.market_price + '</devl>';
                    }
                    var _saleout = _market_price = _zhekou = _sheng = '';
                    var _new_market_price = parseFloat(v.market_price),
                        _new_shop_price = parseFloat(v.shop_price);
                    if (v.goods_number == 0) {
                        _saleout = '<div class="saleout">补货中</div>';
                    }
                    if (_new_market_price > 0) {
                        _market_price = '<del>' + _new_market_price.toFixed(2) + '</del>';
                        if (_new_market_price > _new_shop_price) {
                            var _sm = _new_market_price - _new_shop_price;
                            var _zk = parseFloat(_new_shop_price / _new_market_price) * 10;
                            _zhekou = '<div class="zhekou">' + _zk.toFixed(1) + '折</div>';
                            _sheng = '<div class="sheng">省' + _sm.toFixed(2) + '</div>';
                        }
                    }
               /* <p class="xihuan-bot-each-number">已销' + v.sales_count + '笔</p>                  <p class="xihuan-bot-each-kucun">库存' + v.goods_number + '件</p>*/
                    var _html = '<li class="xihuan-bot-each"><a href="/index/goodsdetail?goods_id=' + v.goods_id + '"><div class="xihuan-bot-each-pic">'+_zhekou+_sheng+_saleout+'<img src="' + _dpic + '" /></div><h2 class="xihuan-bot-each-title">' + v.goods_name + '</h2><div class="xihuan-bot-each-fonu"></div><div class="xihuan-bot-each-fonu">                               </div><div class="xihuan-bot-each-money"><p class="xihuan-bot-each-money-left"><b>' + v.shop_price + '</b></p>' + _del + '</div></a></li>';
                    $("#content").append(_html);
                });
            }
        }, "json");
    }
}

$(".foot_clean").click(function() {
	swal({
	      title: "确定清空所有足迹吗?",
	      type: "warning",
	      timer:10000,
	      cancelButtonText: "取消",
	      showCancelButton: true,
	      closeOnConfirm: false,
	      closeOnCancel: true
	    },
	    function(isConfirm){
	      if (isConfirm){
	           $.ajax({
	                type: 'post',
	                url: "ajax",
	                data: {
	                    act: "footp"
	                },
	                async: false,
	                dataType: 'json',
	                success: function(data) {
	                    if (data.code == 200) {
	                        swal("清空足迹成功！", false, "success");
	                        setTimeout(function() {
	                            window.location.reload();
	                        }, 2100);
	                    } else {
	                        swal(data.msg, false, "error");
	                    }
	                }
	            }) 
	      }
	    });
});
</script>
</body>
</html>